export default {
  methods: {
    // 获取影片票优惠券折扣价
    caclFilmCoupon() {
      const coupons = this.coupons
      const len = coupons.length
      if (len === 0) {
        // 未选优惠券
        return 0
      }
      const isType1 = coupons.find((i) => i.couponType === '1') //兑换券
      let reduceTotal = this.$utils.arrayCalc(coupons, 'reduce') // 立减金额
      const singleSalePrice = this.getSingleSalePrice() // 单张票价
      reduceTotal = this.$utils.getMin([reduceTotal, singleSalePrice]) //实际优惠满减金额不超过单张票价
      if (isType1) {
        //选中兑换券
        //兑换券
        const differenceTotal = this.$utils.arrayCalc(coupons, 'difference')
        const singleSalePrice = this.$utils.isNaNStr(
          this.orderInfo.singleSalePrice
        )
        return len * singleSalePrice - differenceTotal
      } else {
        //优惠券
        return reduceTotal // 立减金额
      }
    },
    // 获取使用优惠券后的折扣价格
    getAfterUserCouponPrice() {
      const filmCoupon = this.caclFilmCoupon()
      return this.$utils.isNaNStr(filmCoupon)
    },
    // 获取单张票价
    getSingleSalePrice() {
      const singleSalePrice = this.orderInfo.singleSalePrice
      return this.$utils.isNaNStr(singleSalePrice)
    },
    // 获取原价  影片价格
    getPrePrice() {
      return this.filmPrice
    },
    // 影片折扣后的价格
    filmDiscount() {
      const p = this.filmPrice - this.caclFilmCoupon()
      return p
    },
    // 获取总座位数(购买票数)
    getTicketNum() {
      return this.$utils.isNaNStr(this.orderInfo.ticketNum)
    }
  }
}
